
#ifndef _NEBULA_SERVICE_SAMPLETASKS_H_
#define _NEBULA_SERVICE_SAMPLETASKS_H_

#include "TaskBase.h"
#include <memory>
#include <string>
#include "Utility/AutoLock.h"

using namespace ::nebula::sdk;

namespace nebula { namespace sample {

// A sample task represents file and key in the encryption service
class PlainTextTask : public TaskBase
{
public:
	//The key interfaces provided by ITask:
	//Framework needs these two interfaces to handle raw data
	virtual NEBULA_ERROR_CODE Serialize  (std::ostream&);
	virtual NEBULA_ERROR_CODE UnSerialize(std::istream&);

public:
	std::string& GetContent();
	
private:
	std::string _content;
};

typedef PlainTextTask EncryptKey;
typedef PlainTextTask EncryptFile;

//In the sample project, this struct is used to store and handle
//service status and handled tasks' statistic
struct RuntimeStat
{
	RuntimeStat();

	void Accumulat(EncryptFile* info);
	void AccumlateEncryption(EncryptFile* info);
	void AccumlateDecryption(EncryptFile* info);

	unsigned file_encrypted;
	unsigned file_decrypted;
	unsigned size_encrypted;
	unsigned size_decrypted;
};

class RuntimeStatTask : public TaskBase
{
public:
	RuntimeStatTask(RuntimeStat* info);

public:
	virtual NEBULA_ERROR_CODE Serialize  (std::ostream&);
	virtual NEBULA_ERROR_CODE UnSerialize(std::istream&);

private:
	unsigned file_encrypted;
	unsigned file_decrypted;
	unsigned size_encrypted;
	unsigned size_decrypted;
};

} } //end of nebula::sample

#endif // end of _NEBULA_SERVICE_SAMPLETASKS_H_
